#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int arr[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int year = 0;
	int month = 0;
	int day = 0;
	int i = 0;
	int sum = 0; 
	scanf("%d %d %d", &year, &month, &day);
	if (year % 4 == 0 && year % 100 != 0)
	{
		arr[1] = 29;
	}
	for (i = 0; i < month - 1; i++)
	{
		sum += arr[i];
	}
	sum += day;
	printf("%d\n", sum);
	return 0;
}



